package com.example.pei.papa.tables;

import android.os.Parcel;
import android.os.Parcelable;

import java.io.Serializable;

import cn.bmob.v3.BmobUser;
import cn.bmob.v3.datatype.BmobFile;

/**
 * Created by PEI on 2017/9/27.
 */

public class UserInfo extends BmobUser implements Parcelable {

    private String headFileUrl;    //头像文件在服务器中url
    private String birthDay;
    private String coverFileUrl;  //封面文件在服务器中url
    private int sex;  //0女 1男

    private int userType;  //用户类型 0代表管理员，1代表普通用户




    public UserInfo(Parcel in){
        //顺序要和writeToParcel写的顺序一样
        setUsername(in.readString());
        setMobilePhoneNumber(in.readString());
        setObjectId(in.readString());
        setSessionToken(in.readString());
        setCreatedAt(in.readString());
        setUpdatedAt(in.readString());
        headFileUrl = in.readString();
        coverFileUrl=in.readString();
        birthDay=in.readString();
        sex = in.readInt();
        userType=in.readInt();

    }

    public UserInfo(){

    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(getUsername());
        dest.writeString(getMobilePhoneNumber());
        dest.writeString(getObjectId());
        dest.writeString(getSessionToken());
        dest.writeString(getCreatedAt());
        dest.writeString(getUpdatedAt());
        dest.writeString(headFileUrl);
        dest.writeString(coverFileUrl);
        dest.writeString(birthDay);
        dest.writeInt(sex);
        dest.writeInt(userType);

    }

    public static final Parcelable.Creator<UserInfo> CREATOR = new Parcelable.Creator<UserInfo>() {
        public UserInfo createFromParcel(Parcel in) {
            return new UserInfo(in);
        }

        public UserInfo[] newArray(int size) {
            return new UserInfo[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    public int getUserType(){return userType;}
    public void setUserType(int userType){this.userType=userType;}
    public String getBirthDay(){return birthDay;}
    public int getSex(){return sex;}
    public String getHeadFileUrl(){return headFileUrl;}
    public String getCoverFileUrl(){return coverFileUrl;}

    public void setBirthDay(String birthDay){this.birthDay=birthDay;}
    public void setSex(int sex){this.sex=sex;}
    public void setHeadFileUrl(String headFileUrl){this.headFileUrl=headFileUrl;}
    public void setCoverFileUrl(String coverFileUrl){this.coverFileUrl=coverFileUrl;}
}
